package com.lht.testDemo;

import org.junit.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author Eric
 * @version 1.0
 * @date 2019-07-03
 */
public class ListAdd {

    @Test
    public void testFilter() {
        List<Integer> arr = new ArrayList<Integer>();
        arr.add(222);
        arr.add(11);
         arr.stream().filter(m -> {
          return m > 20;
        }).forEach(m ->{
             System.out.println(m);
         });
    }

    @Test
    public void test111() {
        String time = "上午(11:00-12:00)";
        String[] times = time.split("\\(")[1].split("\\)")[0].trim().split("-");
        System.out.println(Arrays.toString(times));
    }

    @Test
    public void test22() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(sdf.format(new Date()));
    }

    @Test
    public void testAdd() {
        int input = 8;
        System.out.println(Math.ceil(input / 2.0));
        System.out.println(Math.ceil((input + 1) / 2.0));

        //求一个字符串是否是回文
        String ss = "112324434";
        int one = (int) Math.ceil(ss.length() / 2.0);
        int two = (int) Math.ceil((ss.length() + 1) / 2.0);


        for (int i = 0, j = 0, end = ss.length() - 1; i < one & j < end - two - 1; j++, i++) {

        }
    }

    enum A {
        TT("test"),
        BB("test111");
        private String age;

        A(String age) {
            this.age = age;
        }
    }

    @Test
    public void testEnum() {
        System.out.println(A.TT.ordinal());
    }

    @Test
    public void test() {
        List<Integer> list = new ArrayList<>();

        list.add(1);
        list.add(0, 2);
        for (Integer i : list) {
            System.out.println(i);
        }
    }

    @Test
    public void stringBuildAppend() {
        StringBuilder builder = new StringBuilder("world");
        builder.insert(0, "hello");
        System.out.println(builder.toString());
    }

    @Test
    public void testSimpleDateFormat() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(format.format(new Date()));
    }
}
